package com.tw.academy.basic.$3_feature_envy.practiceTwo;

public class Phone {
    private final String originNumber;
    public static final String NUMBER_FORMAT = "(%s) %s-%s";

    public String getArea() {
        return area;
    }

    public String getPrefix() {
        return prefix;
    }

    public String getNumber() {
        return number;
    }

    private String area;
    private String prefix;
    private String number;

    public Phone(String unformattedNumber) {
        this.originNumber = unformattedNumber;
        this.area = originNumber.substring(0,3);
        this.prefix = originNumber.substring(3,6);
        this.number = originNumber.substring(6,10);
    }

    public String getFormattedNumber() {
        return String.format(NUMBER_FORMAT, this.area, this.prefix, this.number);
    }
}
